$(document).ready(function(){	


			$("#sld").easySlider({
				auto: true, 
				continuous: true,
				nextId: "slider0next",
				prevId: "slider0prev",
				
			});
			$("#sld1").easySlider({
				auto: true, 
				continuous: true,
				nextId: "slider1next",
				prevId: "slider1prev",
			});
			$(".slide_nav2").easySlider({
				auto: true, 
				continuous: true,
				nextId: "slider2next",
				prevId: "slider2prev",
			});
			$(".slide_nav3").easySlider({
				auto: true, 
				continuous: true,
				nextId: "slider3next",
				prevId: "slider3prev",
			});
			$(".slide_nav4").easySlider({
				auto: true, 
				continuous: true,
				nextId: "slider4next",
				prevId: "slider4prev",
			});
			$(".slide_nav5").easySlider({
				auto: true, 
				continuous: true,
				nextId: "slider5next",
				prevId: "slider5prev",
			});
			
		    $(".slide_nav6").easySlider({
				auto: true, 
				continuous: true,
				nextId: "slider6next",
				prevId: "slider6prev",
			});
			$(".slide_nav7").easySlider({
				auto: true, 
				continuous: true,
				nextId: "slider7next",
				prevId: "slider7prev",
			});
			$(".slide_nav8").easySlider({
				auto: true, 
				continuous: true,
				nextId: "slider8next",
				prevId: "slider8prev",
			});
				$(".slide_nav9").easySlider({
				auto: true, 
				continuous: true,
				nextId: "slider9next",
				prevId: "slider9prev",
			});
				$(".slide_nav10").easySlider({
				auto: true, 
				continuous: true,
				nextId: "slider10next",
				prevId: "slider10prev",
			});
				$(".slide_nav11").easySlider({
				auto: true, 
				continuous: true,
				nextId: "slider11next",
				prevId: "slider11prev",
			});
			
		});	

function ClearContent(pItem)
{
	if(pItem.value==pItem.defaultValue)
	{	
		pItem.value="";	
	}
}
	
function FillContent(pItem)
{
	if(pItem.value=="")
		pItem.value=pItem.defaultValue;
}

function printWindow()
{
	window.open(document.frmSearch.hdnprint.value+"?print=1",null,"top=0,left=0,height=500,width=635,status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no");
}

function gopage(ppage,pstr)
{
	var doc = document.frmSearchResults;
	doc.SearchBox.value = pstr;
	doc.page.value = ppage;
	doc.action = "search_results.asp";
	doc.submit();
}

// Dynamic hide/showdivs
function showdiv(pdivid,pid)
{
	var aDivs = document.body.getElementsByTagName("DIV");
	
	// first hide all divs (only required div's not all)
	for(var i=pid ; i< aDivs.length; i++)
	{
		if (aDivs[i].id.substring(0,4) == 'div_')
		{
			aDivs[i].style.display = 'none';
		}
	} 
	
	if (document.layers) 	//IS NETSCAPE 4 or below 
	{ 
		document.layers[pdivid].display = 'block'; 
	}
	else			//IS IE
	{
		// show the wanted one
		var showItem = document.getElementById(pdivid); 
		showItem.style.display = 'block'; 
	}
}

function showSelectedDiv(psec,pdivid)
{
	if(document.frm1.hdnSection.value==psec)
	{
	document.frm1.action = psec + ".asp"
	document.frm1.submit();
	document.getElementById(pdivid).style.display = 'block'; 
	}
}

function showdefaultdiv()
{
	showdiv('div_0');
}

function IsEmail(str) 
{
	// are regular expressions supported?
  	var supported = 0;
  	if (window.RegExp) 
	{
  			var tempStr = "a";
  			var tempReg = new RegExp(tempStr);
    	if (tempReg.test(tempStr)) supported = 1;
  	}
  	if (!supported) 
  			return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
	  	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	  	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	  	return (!r1.test(str) && r2.test(str));
}

function validateform()
{
	var doc = document.contactForm;

	if (doc.name.value == "")
	{
		alert("Please enter your name.");
		doc.name.focus();
		return false;		
	}
	
	if (doc.company.value == "")
	{
		alert("Please enter a your company.");
		doc.company.focus();
		return false;
	}
	
	if (doc.telephone.value == "")
	{
		alert("Please enter telephone number.");
		doc.telephone.focus();
		return false;
	}
	
	if (doc.email.value == "")
	{
		alert("Please enter a valid email.");
		doc.email.focus();
		return false;
	}
	
	if (!IsEmail(doc.email.value))
		{
			alert ('Please check that the email address is valid.');
			doc.email.focus();
			return false;
		}
	
	if (doc.website.value == "")
	{
		alert("Please enter your website.");
		doc.website.focus();
		return false;		
	}
	
	if (doc.aboutus.value == "")
	{
		alert("Please select How did you find out about Twice Creative.");
		doc.aboutus.focus();
		return false;
	}
	
	if (doc.descp.value == "")
	{
		alert("Please enter a description.");
		doc.descp.focus();
		return false;
	}
	
	
	return true;
}

function validateNewsletter()
{
	var doc = document.frm1;

	if (doc.txtemail.value == "")
	{
		alert("Please enter a valid email.");
		doc.txtemail.focus();
		return false;
	}
	
	if (!IsEmail(doc.txtemail.value))
		{
			alert ('Please check the email address is valid.');
			doc.txtemail.focus();
			return false;
		}
	
}

var pSelectedIndex;
var pIndex;
var vDefaultImg;

myDynArray = new Array();

function animateImage(pImgIndex)
{
	if(vDefaultImg == undefined)
		vDefaultImg = document.bigImg.src;
	if(pImgIndex == "")
		document.bigImg.src = vDefaultImg;
	else
		document.bigImg.src = myDynArray[pImgIndex].replace("_s","_l");;
}

function popupWindow(pImgIndex)
{
	pSelectedIndex = pImgIndex;
	window.open("viewImage.asp",null,"location=0,left=20,top=20,width=650,height=600,toolbar=0,resizable=1,status=0");
}

function initializeValues()
{
	myDynArray = window.opener.myDynArray;
	
	document.img.src = myDynArray[window.opener.pSelectedIndex];
	
	if(window.opener.pSelectedIndex < myDynArray.length && window.opener.pSelectedIndex > 0)
		document.getElementById("pre").style.display = 'block';
	
	if(window.opener.pSelectedIndex < myDynArray.length - 1 && window.opener.pSelectedIndex >= 0)
		document.getElementById("next").style.display = 'block';
}

function showPre()
{
	if(pIndex == undefined)
	pIndex = window.opener.pSelectedIndex;
	
	if(pIndex <= myDynArray.length - 1)
		pIndex = parseInt(pIndex) - 1;
	
	document.img.src = myDynArray[parseInt(pIndex)].replace("_s","_l");
	document.getElementById("next").style.display = 'block';
	
	if(pIndex <= 0)
		document.getElementById("pre").style.display = 'none';
}

function showNext()
{
	if(pIndex == undefined)
	pIndex = window.opener.pSelectedIndex;
	
	if(pIndex < myDynArray.length - 1)
		pIndex = parseInt(pIndex) + 1;
	
	document.img.src = myDynArray[parseInt(pIndex)].replace("_s","_l");
	document.getElementById("pre").style.display = 'block';
	
	if(pIndex >= myDynArray.length - 1)
		document.getElementById("next").style.display = 'none';
}



// Subpages slider

$(document).ready(function(){
    $('.lightbox').lightbox();
  });

$(function() {

    $('#leftSide_slider_v').cycle({
        fx:      'fade',
        prev:    '#prev',
        next:    '#next',
		speed:   1800, 
		timeout: 1400,
    });
	
	$('#leftSide_slider_h, #fullSlide').cycle({
        fx:      'fade',
        prev:    '#prev',
        next:    '#next',
		speed:   1800, 
		timeout: 1400,
    });
	
	
	

  
});


// Detailed portfolio slider

		function mycarousel_initCallback(carousel)
		{
				// Disable autoscrolling if the user clicks the prev or next button.
				carousel.buttonNext.bind('click', function() {
					carousel.startAuto(1);
				});

				carousel.buttonPrev.bind('click', function() {
					carousel.startAuto(1);
				});

				// Pause autoscrolling if the user moves with the cursor over the clip.
				carousel.clip.hover(function() {
					carousel.stopAuto();
				}, function() {
					carousel.startAuto();
				});
			};

			
			jQuery(document).ready(function() {
				jQuery('.mycarousel').jcarousel({
					wrap: 'last',
					scroll: 1,
				});
			});
															
													


// Large portfolio slider

	$(document).ready(function(){
	

		$('.slider').advancedSlider({width:734, height:400, slideProperties:{
			0:{effectType:'fade', horizontalSlices:'1', verticalSlices:'1', slicePattern:'leftToRight'},
			1:{effectType:'fade', horizontalSlices:'1', verticalSlices:'1', slicePattern:'leftToRight'},
			2:{effectType:'fade', horizontalSlices:'1', verticalSlices:'1', slicePattern:'leftToRight'},
			3:{effectType:'fade', horizontalSlices:'1', verticalSlices:'1', slicePattern:'leftToRight'},
			4:{effectType:'fade', horizontalSlices:'1', verticalSlices:'1', slicePattern:'leftToRight'},
			5:{effectType:'fade', horizontalSlices:'1', verticalSlices:'1', slicePattern:'leftToRight'},
			6:{effectType:'fade', horizontalSlices:'1', verticalSlices:'1', slicePattern:'leftToRight'},
			7:{effectType:'fade', horizontalSlices:'1', verticalSlices:'1', slicePattern:'leftToRight'},
			8:{effectType:'fade', horizontalSlices:'1', verticalSlices:'1', slicePattern:'leftToRight'},
			9:{effectType:'fade', horizontalSlices:'1', verticalSlices:'1', slicePattern:'leftToRight'},
			10:{effectType:'fade', horizontalSlices:'1', verticalSlices:'1', slicePattern:'leftToRight'},
			11:{effectType:'fade', horizontalSlices:'1', verticalSlices:'1', slicePattern:'leftToRight'},
		}});

		$(function () {

		// get current slide's number
		function currentSlide() {
			var hash = window.location.hash || '#work-1';
			return parseInt(hash.replace(/[A-Za-z#\-\/!]/g, '') - 1); 
		}
		// global vars	
		var	cycleSelector = $('.slideshow'),
				startSlide = currentSlide(),
				hasSlid = 0;
		
		// append some markup for the controls		
		cycleSelector.before('<div id="nav"><ul/></div>') 
		// start jQuery Cycle	
		.cycle({ 
			 startingSlide: startSlide,
			 // when using the next/prev links
		 onPrevNextEvent: function(isNext, idx, slide) { 
			hasSlid = 1;
			window.location.hash = "work-"+ (parseInt(idx) + 1) + ""; 
			return false;
		 },
		 // when using the pager thumbnails
		 onPagerEvent: function(idx, slide) { 
			hasSlid = 1;
			window.location.hash = "work-"+ (parseInt(idx) + 1) + ""; 
			
			return false;
		 },
		 timeout: 0, 
		 pager:  '#nav ul',
		 speed: 1000,
		});
		
		// bind to the hashchange event
		$(window).bind('hashchange', function () {
				var slideNo = currentSlide();
				// we only want to fire the slide change if the next button or the pager hasn't done it for us
				if (hasSlid === 0) { cycleSelector.cycle(slideNo); }
				// return it back to zero
				hasSlid = 0;
		}); 
		
		// when the page loads, we need to trigger a hashchange
		$(window).trigger( "hashchange" );
		
	});
	
	$(function () {

		// get current slide's number
		function currentSlide() {
			var hash = window.location.hash || '#work-1';
			return parseInt(hash.replace(/[A-Za-z#\-\/!]/g, '') - 1); 
		}
		// global vars	
		var	cycleSelector = $('.slideshow_sub'),
				startSlide = currentSlide(),
				hasSlid = 0;
		
		// append some markup for the controls		
		cycleSelector.before('<div id="nav"><ul/></div>') 
		// start jQuery Cycle	
		.cycle({ 
			 startingSlide: startSlide,
			 // when using the next/prev links
		 onPrevNextEvent: function(isNext, idx, slide) { 
			hasSlid = 1;
			window.location.hash = "work-"+ (parseInt(idx) + 1) + ""; 
			return false;
		 },
		 // when using the pager thumbnails
		 onPagerEvent: function(idx, slide) { 
			hasSlid = 1;
			window.location.hash = "work-"+ (parseInt(idx) + 1) + ""; 
			
			return false;
		 },
		 timeout: 0, 
		 speed: 1000,
		});
		
		// bind to the hashchange event
		$(window).bind('hashchange', function () {
				var slideNo = currentSlide();
				// we only want to fire the slide change if the next button or the pager hasn't done it for us
				if (hasSlid === 0) { cycleSelector.cycle(slideNo); }
				// return it back to zero
				hasSlid = 0;
		}); 
		
		// when the page loads, we need to trigger a hashchange
		$(window).trigger( "hashchange" );
		
	});

															



		});

