//Clone what we've got



function tellafriend()
		{
	//alert(tbnam);
   window.open('tell_friend.php','mywindow','width=500,height=450,status=yes,copyhistory=yes,  resizable=yes, left=0,top=0,screenX=0,screenY=100,scrollbars=yes');
}

stepcarousel.setup({
	galleryid: 'mygallery', //id of carousel DIV
	beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
	panelclass: 'panel', //class of panel DIVs each holding content
	autostep: {enable:true, moveby:1, pause:3000},
	panelbehavior: {speed:500, wraparound:true, wrapbehavior:'slide', persist:false},
	defaultbuttons: {enable: false, moveby: 1, leftnav: ['images/arrow_left.png', -550, 210], rightnav: ['images/arrow_right.png',-30, 210]},
	statusvars: ['statusA', 'statusB', 'statusC'], //register 3 variables that contain current panel (start), current panel (last), and total panels
	contenttype: ['inline'] //content setting ['inline'] or ['ajax', 'path_to_external_file']
})

stepcarousel.setup({
	galleryid: 'mygallery-season', //id of carousel DIV
	beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
	panelclass: 'panel', //class of panel DIVs each holding content
	autostep: {enable:true, moveby:1, pause:3000},
	panelbehavior: {speed:500, wraparound:true, wrapbehavior:'slide', persist:false},
	statusvars: ['statusA', 'statusB', 'statusC'], //register 3 variables that contain current panel (start), current panel (last), and total panels
	contenttype: ['inline'] //content setting ['inline'] or ['ajax', 'path_to_external_file']
})

function cloner(){
	// Pad before
	var smfirst = $('#features_list li:first');
	var smfirstclass = $(smfirst).attr('class');
	$('#features_list_container li').each(function(){
		$(this).clone(true).insertBefore(smfirst);
	})
	lgfirst = $('#feature_panes li:first');
	$('#features_panes_container li').each(function(){
		$(this).clone(true).insertBefore(lgfirst);
	})

	// Advance to the ones we need
	$('#features_list_wrapper').css('left', (liL * lisW * limb * -1) - (offset * lisW)  + 'px');
	$('#feature_panes_wrapper').css('left', (liL * lilW * limb * -1) + 'px');
	
	// Uncomment if you want them to match
	//$('#feature_panes_wrapper').css('left', (liL * lilW * limb * -1) - (offset * lisW) + 'px');
	
	
	//Account for new length
	t = $('#features_list_container li').length
	
	// Pad after
	$('#features_list_container li:gt(' + ((t/2)-1) + ')').each(function(){
		smlast = $('#features_list li:last');
		$(this).clone(true).insertAfter(smlast);
	})
	$('#features_panes_container li:gt(' + ((t/2)-1) + ')').each(function(){
		lglast = $('#feature_panes li:last');
		$(this).clone(true).insertAfter(lglast);
	})
	
	// We hide the first item so it wont show up when the page loads. After we are done initalizing - we show it.
	$('.' + smfirstclass).css('display', 'block');
	
	//Update the li length
	liL		= $('#features_list_container li').length;
}

function adv(){
	inc = inc + 1;
	if(inc >= 1 && inc <= ((liL/3)*2)){
		move(inc, -1);
	}
}
function rev(){
	inc = inc - 1;
	if(inc >= 1 && inc <= ((liL/3)*2)){
		move(inc, 1);
	}
}


function move(page, d){
	var dir = d;
	
	//Depending on Direction - calculate how much to the Small Feature Bar
	if(d == 1){
		swp = ((page + limb + offset) * lisW * dir);
	}else{
		swp = (page * lisW * dir);
	}
	
	//Depending on Direction - calculate how much to the Large Feature Bar
	if(d == 1){
		lwp = ((page + offset) * lilW * dir);
	}else{
		lwp = ((page - offset) * lilW * dir);
	}
	
	
	if(dir == -1){
		// Amts = (LI Width (large or Small) * direction * li Move By) + large or small Wrapper Position
		var samt = (lisW * dir * limb) + swp;
		var lamt = (lilW * dir * limb) + lwp;
	}else{
		var samt = (lisW * dir * limb) - swp;
		var lamt = (lilW * dir * limb) - lwp;
	}
	
	
	$('#features_list_wrapper').animate({ left : samt  }, 500, function(){
		//FWD
		if(dir == -1){
			// At the 3/4 mark we are going to adjust the CSS
			if(page == ((liL/3)*2)){
				
				// Calculate the amount we need to move (adjust for offset)
				var amt = (-1 * (liL/3) * lisW) - (offset * lisW);
				$('#features_list_wrapper').css({ left : amt  });
				
				// Set Incrementer back to the 1/3 mark (or the first panel that is shown onload)
				inc = (liL / 3);
			}
		}
		//REV
		if(dir == 1){	
			// At the first item we are going to adjust the CSS + be sure to include the offset
			if(page == 1){
				
				// Calculate the amount we need to move (adjust for offset)
				var amt = (-1 * ((liL/3)+offset) * lisW) - (offset * lisW);
				$('#features_list_wrapper').css({ left : amt  });
				
				// Set Incrementer back to the 1/3 mark (or the first panel that is shown onload + 1 because of the offset)
				inc = ((liL / 3) + offset); 
			}
		}
	});

	
	
	$('#feature_panes_wrapper').animate({ left : lamt  }, 500, function(){
		//FWD
		if(dir == -1){
			// At the 3/4 mark we are going to adjust the CSS
			if(page == ((liL/3)*2)){
				
				// Calculate the amount we need to move
				var amt = (-1 * (liL/3) * lilW);
				$('#feature_panes_wrapper').css({ left : amt  });
				
				// Set Incrementer back to the 1/3 mark (or the first panel that is shown onload)
				inc = (liL / 3);
			}
		}
		//REV
		if(dir == 1){
			if(page == 1){
				
				// At the first item we are going to adjust the CSS + be sure to include the offset
				var amt = (-1 * ((liL/3)+offset) * lilW);
				$('#feature_panes_wrapper').css({ left : amt  });
				
				// Set Incrementer back to the 1/3 mark (or the first panel that is shown onload + 1 because of the offset)
				inc = ((liL / 3) + offset); 
			}
		}
	});
	
}

function init(){
	cloner();
	
	jQuery('#feature_arrows li.fwd a').click(function(){
		 animate = false;
		 adv();
		 return false;
	})

	jQuery('#feature_arrows li.rev a').click(function(){
		 animate = false;
		 rev();
		 return false;
	})

}	

$(document).ready(function () {
  
	liL		= $('#features_list_container li').length
	lisW 	= 395; 				// make sure to add margins & padding width = 322px + 1px right-margin
	lilW 	= 980; 				// make sure to add margins & padding width = 322px + 1px right-margin
	limb 	= 1; 				// li to move by
	offset 	= 1;				// Featurette offest (moves X items to the left)
	animate = true;	
	inc 	= liL;				// Set incrementer at the position of the first panel shown onload
	
	
	$(document).everyTime(10000, "features", function(i) {
		if (animate == true) {
			adv();			
		}
	});

	init();
  
});
/********enquiry form********/


function checkenquiry_form()
{	
	docf=document.getElementById("frm");
	if(docf.name.value=="")
	{
		alert("Enter your Name");
		docf.name.focus();
		return false;
	}
	
	if(docf.address.value=="")
	{
		alert("Enter your Address");
		docf.address.focus();
		return false;
	}
	
if(docf.phone.value=="")
	{
		alert("Enter your phone");
		docf.phone.focus();
		return false;
	}

	
	if(docf.email.value=="")
	{
		alert("Enter your Email Id");
		docf.email.focus();
		return false;
	}	

if(docf.city.value=="")
	{
		alert("Pleace enter the city");
		docf.city.focus();
		return false;
	}

if(docf.country.value=="NA")
	{
		alert("Pleace Select Your Country");
		docf.country.focus();
		return false;
	}

	if(docf.code_field.value=="")
	{
		alert("Enter the code");
		docf.code_field.focus();
		return false;	
	}
	return validate_form(docf);	
}


function validate_email(field,alerttxt)
{
	with (field)
	{
		apos=value.indexOf("@")
		dotpos=value.lastIndexOf(".")
		if (apos<1||dotpos-apos<2) 
  		{
  			alert(alerttxt);
  			return false;
  		}
		else 
		{
			return true;
		}
	}
	
}


function validate_form(thisform)
{
	with (thisform)
	{
		if (validate_email(email,"Not a valid e-mail address!")==false)
  		{
  			email.focus();
  			return false;
  		}
	}
	
}


//////////////////THIS FUNCTION CHECK ANY GIVEN PHONE NO.
function isValidPhone(phone){
var numstr="1234567890+-, ";
var intctr,intLen;
    intLen=phone.length;
        for(intCtr=0;intCtr <= intLen && numstr.indexOf(phone.charAt(intCtr))>=0 ;intCtr++);
        if(intCtr > intLen)
              return true;
        else
              return false;
      
}
///////////////////////////////////////////////////////////////////

/********send-enquiry form********/


function sendcheckenquiry_form()
{	
	docf=document.getElementById("frms");
	if(docf.name.value=="")
	{
		alert("Enter your Name");
		docf.name.focus();
		return false;
	}
	
	
	
if(docf.phone.value=="")
	{
		alert("Enter your phone");
		docf.phone.focus();
		return false;
	}

	
	if(docf.email.value=="")
	{
		alert("Enter your Email Id");
		docf.email.focus();
		return false;
	}	

if(docf.date.value=="")
	{
		alert("Pleace enter the Date");
		docf.date.focus();
		return false;
	}


	if(docf.code_field.value=="")
	{
		alert("Enter the code");
		docf.code_field.focus();
		return false;	
	}
	return validate_form(docf);	
}


function validate_email(field,alerttxt)
{
	with (field)
	{
		apos=value.indexOf("@")
		dotpos=value.lastIndexOf(".")
		if (apos<1||dotpos-apos<2) 
  		{
  			alert(alerttxt);
  			return false;
  		}
		else 
		{
			return true;
		}
	}
	
}


function validate_form(thisform)
{
	with (thisform)
	{
		if (validate_email(email,"Not a valid e-mail address!")==false)
  		{
  			email.focus();
  			return false;
  		}
	}
	
}


//////////////////THIS FUNCTION CHECK ANY GIVEN PHONE NO.
function isValidPhone(phone){
var numstr="1234567890+-, ";
var intctr,intLen;
    intLen=phone.length;
        for(intCtr=0;intCtr <= intLen && numstr.indexOf(phone.charAt(intCtr))>=0 ;intCtr++);
        if(intCtr > intLen)
              return true;
        else
              return false;
      
}
///////////////////////////////////////////////////////////////////









/********feedback form********/


function feedback_form()
{	
	docf=document.getElementById("frmfeed");
	if(docf.name.value=="")
	{
		alert("Enter your Name");
		docf.name.focus();
		return false;
	}
	

	if(docf.email.value=="")
	{
		alert("Enter your Email Id");
		docf.email.focus();
		return false;
	}	


function validate_email(field,alerttxt)
{
	with (field)
	{
		apos=value.indexOf("@")
		dotpos=value.lastIndexOf(".")
		if (apos<1||dotpos-apos<2) 
  		{
  			alert(alerttxt);
  			return false;
  		}
		else 
		{
			return true;
		}
	}
	
}

if(docf.code_field.value=="")
	{
		alert("Enter the code");
		docf.code_field.focus();
		return false;	
	}
	return validate_form(docf);	



function validate_form(thisform)
{
	with (thisform)
	{
		if (validate_email(email,"Not a valid e-mail address!")==false)
  		{
  			email.focus();
  			return false;
  		}
	}
	
}


//////////////////THIS FUNCTION CHECK ANY GIVEN PHONE NO.
function isValidPhone(phone){
var numstr="1234567890+-, ";
var intctr,intLen;
    intLen=phone.length;
        for(intCtr=0;intCtr <= intLen && numstr.indexOf(phone.charAt(intCtr))>=0 ;intCtr++);
        if(intCtr > intLen)
              return true;
        else
              return false;
      
}
}


function sendlink(prdid){
window.open('sendenquiry.php?prdid='+prdid,'mywindow','width=590,height=450,status=no,copyhistory=yes,  resizable=yes,scrollbars=yes,menubar=0, left=0,top=0,screenX=0,screenY=100');
}
///////////////////////////////////////////////////////////////////




/********feedback form********/


function indfeedback_form()
{	
	docf=document.getElementById("indfrmfeed");
	if(docf.name.value=="")
	{
		alert("Enter your Name");
		docf.name.focus();
		return false;
	}
	

	if(docf.email.value=="")
	{
		alert("Enter your Email Id");
		docf.email.focus();
		return false;
	}	


function validate_email(field,alerttxt)
{
	with (field)
	{
		apos=value.indexOf("@")
		dotpos=value.lastIndexOf(".")
		if (apos<1||dotpos-apos<2) 
  		{
  			alert(alerttxt);
  			return false;
  		}
		else 
		{
			return true;
		}
	}
	
}

if(docf.code_field.value=="")
	{
		alert("Enter the code");
		docf.code_field.focus();
		return false;	
	}
	return validate_form(docf);	



function validate_form(thisform)
{
	with (thisform)
	{
		if (validate_email(email,"Not a valid e-mail address!")==false)
  		{
  			email.focus();
  			return false;
  		}
	}
	
}


//////////////////THIS FUNCTION CHECK ANY GIVEN PHONE NO.
function isValidPhone(phone){
var numstr="1234567890+-, ";
var intctr,intLen;
    intLen=phone.length;
        for(intCtr=0;intCtr <= intLen && numstr.indexOf(phone.charAt(intCtr))>=0 ;intCtr++);
        if(intCtr > intLen)
              return true;
        else
              return false;
      
}
}

