// JavaScript Document

function newSize(){
	//window.innerWidth
   var viewportH=window.innerHeight;
   var navHeight=127;
	var frameHeight=viewportH-navHeight;
	
	//document.getElementById('contentFrame').style.height=frameHeight+"px";
	document.getElementById('contentFrame').height=frameHeight+"px";
}


function navChange(){
var splitter=document.title;
var pageName=splitter.split(" ");
var changeIt=pageName[3].toLowerCase();

var theTag=document.getElementById(changeIt);

if (changeIt=="home" || changeIt=="products" || changeIt=="collections" || changeIt=="decorations" || changeIt=="contact" || changeIt=="specs" || changeIt=="upload" ){
theTag.style.color="#007dc3";
}
/*if (changeIt=="home" || changeIt=="products" || changeIt=="collections" || changeIt=="decorations" || changeIt=="contact" || changeIt=="specs" || changeIt=="upload" ){
theTag.style.backgroundImage="url(images/rollovers/"+changeIt+".png)";

theTag.style.backgroundRepeat="no-repeat";
theTag.style.color="#007dc3";
theTag.onmouseout="";
}*/

}


function rollOver(theLink){
	var changeThis=document.getElementById(theLink);
	changeThis.style.backgroundImage="url(images/rollovers/"+theLink+".png)";
	changeThis.style.backgroundRepeat="no-repeat";
}

function rollOut(theLink){
	var changeBack=document.getElementById(theLink);
	changeBack.style.backgroundImage="none";
}


function clientPop(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=490,height=435,left=200,top=50');");
}


function showCase(upORdown,curPic,totPic) {
filePath="images/cstudies/";

if (upORdown=="next"){
	targe=curPic+1;
	whichpic=filePath+targe+".jpg";
}else{
	targe=curPic-1;
	whichpic=filePath+targe+".jpg"
}

document.getElementById('casepic').src = whichpic;	


//prevPic=curPic-1;
//nextPic=curPic+1;

nextLink=" <a href=\"javascript: showCase('next',"+targe+","+totPic+");\">| next ></a>";
prevLink="<a href=\"javascript: showCase('prev',"+targe+","+totPic+");\">< previous |</a> ";

if (targe==1){
	$message=targe+" of "+totPic+nextLink;
} else if (targe==totPic){
	$message=prevLink+targe+" of "+totPic;
} else{
	$message=prevLink+targe+" of "+totPic+nextLink;
}

	
document.getElementById('casePicCaption').innerHTML=$message;

}


	/*------------------------- BLOG FEED -------------------------------- */
	
function getFeed(sender, uri) {
    jQuery.getFeed({
        url: 'incl/proxy.php?url=' + uri,
        success: function(feed) {
            jQuery(sender).append('<h2>'
            + '<a href="'
            + feed.link
            + '">'
            + feed.title
            + '</a>'
            + '</h2>');

            var html = '';

            //for(var i = 0; i < feed.items.length && i < 5; i++) {
for(var i = 0; i < feed.items.length && i < 1; i++) {
                var item = feed.items[i];

                html += '<h3>'
                + '<a href="'
                + item.link
                + '">'
                + item.title
                + '</a>'
                + '</h3>';

                html += '<div class="updated">'
                + item.updated
                + '</div>';

                html += '<div>'
                + item.description
                + '</div>';
            }

            jQuery(sender).append(html);
        }    
    });
}
	
	
	
	
	/*------------------------- END BLOG FEED -------------------------------- */

function pageInit(){
	
	/*getFeed($("#blogfeed"), 'http://www.edventurepromotions.com/blog/?feed=rss');*/
	
	
		$('#sameInfo').click(function(){
		if ($('#sameInfo').attr('checked')) {
     
	 	$('#shippingInformation').hide();

				} else {
	$('#shippingInformation').show();

	
			}
			 });
	
	//$(".awardMovie").colorbox({maxHeight:'220px',maxWidth:'400px'});
	//$(".awardMovie").colorbox();
	//$(".awardMovie").colorbox({innerHeight:'240px',innerWidth:'400px'});
	
	
	$('#blog').mouseover(function(){$('#sideImg').attr('src','images/rollovers/pageSide_blog.gif');});
	$('#blog').mouseout(function(){$('#sideImg').attr('src','images/rollovers/pageSide.gif');});
	
	$('#testimonials').mouseover(function(){$('#sideImg').attr('src','images/rollovers/pageSide_testimonial.gif');});
	$('#testimonials').mouseout(function(){$('#sideImg').attr('src','images/rollovers/pageSide.gif');});
	
	///// form validation
	
	
	$('#submitForm').click(function(){
		
		var errorCount=0;
		
		$('.warning').remove();
		
		
		
		
		if ($('#billingName').val()==""){
		$('#billingName').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}
		
		if ($('#billingAddress').val()==""){
		$('#billingAddress').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}
		
		/*if ($('#billingAddress2').val()==""){
		$('#billingAddress2').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}*/
		
		if ($('#billingCity').val()==""){
		$('#billingCity').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}
		
		if ($('#billingState').val()==""){
		$('#billingState').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}
		
		if ($('#billingZip').val()==""){
		$('#billingZip').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}
		
		if ($('#billingEmail').val()==""){
		$('#billingEmail').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}
		
		if ($('#billingPhone').val()==""){
		$('#billingPhone').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}
		




if ($('#sameInfo').attr('checked')) {
     
		var skipInfo="none";

				} else {
			
		
		if ($('#shippingName').val()==""){
		$('#shippingName').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}
		
		if ($('#shippingAddress').val()==""){
		$('#shippingAddress').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}
		
		/*if ($('#shippingAddress2').val()==""){
		$('#shippingAddress2').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}*/
		
		if ($('#shippingCity').val()==""){
		$('#shippingCity').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}
		
		if ($('#shippingState').val()==""){
		$('#shippingState').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}
		
		if ($('#shippingZip').val()==""){
		$('#shippingZip').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}
		
		if ($('#shippingEmail').val()==""){
		$('#shippingEmail').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}
		
		if ($('#shippingPhone').val()==""){
		$('#shippingPhone').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}
							
			}	// end the else for the shipping information			
							
							
							
							
		
		
		if ($('#itemNumber').val()==""){
		$('#itemNumber').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}
		
		if ($('#itemDescription').val()==""){
		$('#itemDescription').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}
		
		
		if (($('#inHandsMonth').val()=="") || ($('#inHandsDay').val()=="") || ($('#inHandsYear').val()=="")){
		$('#inHandsYear').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}
		
		
		/*if ($('#inHandsMonth').val()==""){
		$('#inHandsMonth').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}
		
		if ($('#inHandsDay').val()==""){
		$('#inHandsDay').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}
		
		
		if ($('#inHandsYear').val()==""){
		$('#inHandsYear').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}*/
		
		
		if ($('#itemColor').val()==""){
		$('#itemColor').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}
		
		if ($('#quantity').val()==""){
		$('#quantity').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}
		
		if ($('#imprintColor').val()==""){
		$('#imprintColor').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}
		
		if ($('#imprintLocation').val()==""){
		$('#imprintLocation').after("<strong class='warning'> *</strong>");	
		errorCount++;
		}
		
		
		//$('#specialInstructions').val()

		if (errorCount==0){
			$('#orderForm').submit();	
		} else {
		$('#validationMessage').html("<strong class='warning'> You are missing some required information</strong>");
		
		$('body,html').animate({scrollTop:0},100); 
		}
								   
								   });
	
	
	
	
	
	
	
	
	
	
	
}





function popUp(URL,winWidth,winHeight) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+winWidth+",height="+winHeight+",left=100,top=100');");
}





